/**
 * Created by 小敏哥 on 2017/3/23.
 */
import updateCarInfoService from '../services/updateCarInfoService';
import {Toast} from 'antd-mobile';
export const getCheckDate=(data,callBack)=>{
    return (dispatch, getState) => {
        Toast.hide();
        Toast.loading("", 30, () => Toast.info("网络错误", 2));
        updateCarInfoService.getCheckDate(data).then(resultData=>{
            Toast.hide();
            if (resultData.code == 1000) {
                if(callBack) {
                    callBack(resultData.data.dateList);
                }
            }
            else {
                Toast.info(resultData.msg, 2);
            }
        })
    }
};

//修改车辆信息
export const updateCar= (data, callBack) => {
    return (dispatch, getState)=>{
        Toast.hide();
        Toast.loading("", 30, () => Toast.info("网络错误", 2));
        updateCarInfoService.updateCar(data).then(resultData=>{
            Toast.hide();
            if (resultData.code == 1000) {
                callBack();
            }
            else {
                Toast.info(resultData.msg, 2);
            }
        })
    }
};
//删除车辆信息
export const deleteCar= (data, callBack) => {
    return (dispatch, getState)=>{
        Toast.hide();
        Toast.loading("", 30, () => Toast.info("网络错误", 2));
        updateCarInfoService.deleteCar(data).then(resultData=>{
            Toast.hide();
            if (resultData.code == 1000) {
                callBack();
            }
            else {
                Toast.info(resultData.msg, 2);
            }
        })
    }
};
//获取车辆信息
export const getCarInfo=(data, callBack) => {
    return (dispatch, getState)=>{
        Toast.hide();
        Toast.loading("", 30, () => Toast.info("网络错误", 2));
        updateCarInfoService.getCarInfo(data).then(resultData=>{
            Toast.hide();
            if (resultData.code == 1000) {
                callBack(resultData.data);
            }
            else {
                Toast.info(resultData.msg, 2);
            }
        })
    }
};
/*

//增加车辆
export  const addCar=(data,callBack)=>{
    return (dispatch, getState) => {
        Toast.hide();
        Toast.loading("", 30, () => Toast.info("网络错误", 2));
        updateCarInfoService.addCar(data).then(resultData=>{
            Toast.hide();
            if (resultData.code == 1000) {
                if(callBack) {
                    callBack(resultData.data.resultFlag);
                }
            }
            else {
                Toast.info(resultData.msg, 2);
            }
        })
    }
};

//删除车辆
export  const subCar=(data,callBack)=>{
    return (dispatch, getState) => {
        Toast.hide();
        Toast.loading("", 30, () => Toast.info("网络错误", 2));
        updateCarInfoService.subCar(data).then(resultData=>{
            Toast.hide();
            if (resultData.code == 1000) {
                if(callBack) {
                    callBack(resultData.data.resultFlag);
                }
            }
            else {
                Toast.info(resultData.msg, 2);
            }
        })
    }
};
*/
